package com.hns.can.report.service;

import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.report.entity.ModDateTyAutoEntity;
import com.hns.can.report.entity.ModTyBadBhvBencEntity;
import com.hns.can.report.entity.ModTyBadBhvInfoEntity;
import com.hns.can.report.entity.ModTyBadBhvTypeEntity;
import com.hns.can.report.vo.LineAreaBadBhvSortVo;
import com.hns.can.report.vo.lineDrvStandardVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 线路驾驶员规范分析-业务类
 *
 * @author # xujf（835264047@qq.com）
 * @date # 2017-02-15 10:25:14
 */
@Service
public class LineDrvStandardService extends CommonService {

    @Autowired
    private FillCodeDscValue codeDscValue;

    // todo 线路区域不良行为排名

    /**
     * 线路区域不良行为排名
     *
     * @param vo
     * @return
     */
    public Map<String, Object> getLineAreaBadBhvSortList(lineDrvStandardVo vo) {
        Map<String, Object> rstMap = new HashMap<String, Object>();


        String filterConditionSql = getBhvList4fltSql("SUM_BHV_FREQ");
        vo.setFilterConditionSql(filterConditionSql);

        // 黑点区域
        vo.setAreaType("B");
        List<LineAreaBadBhvSortVo> dataList1 = getLineAreaBadBhvSortListByAreaType(vo);
        rstMap.put("blackSpot", dataList1);

        // 站点区域
        vo.setAreaType("S");
        List<LineAreaBadBhvSortVo> dataList2 = getLineAreaBadBhvSortListByAreaType(vo);
        rstMap.put("site", dataList2);

        // 站点间区域
        vo.setAreaType("BS");
        List<LineAreaBadBhvSortVo> dataList3 = getLineAreaBadBhvSortListByAreaType(vo);
        rstMap.put("siteInterval", dataList3);

        // 非营运
        vo.setAreaType("OL");
        List<LineAreaBadBhvSortVo> dataList4 = getLineAreaBadBhvSortListByAreaType(vo);
        rstMap.put("noOpt", dataList4);


        // 获取相关行为信息
        Map<String, Object> badBhvInfo = getBadBhvInfo();
        rstMap.put("badBhvInfo", badBhvInfo);


        // 获取区域统计信息
        List<LineAreaBadBhvSortVo> dataList5 = getLineAreaBadBhvInfoList(vo);
        rstMap.put("lineAreaBadBhvInfo", dataList5);


        // 获取日期类型所对应的日期区间
        String dateTy = vo.getDateTy();
        vo.setTdateTy(dateTy);
        dateType2DateTime(vo);

        Map timeMap = new HashMap();
        timeMap.put("beginTime", vo.getBeginTime());
        timeMap.put("endTime", vo.getEndTime());

        rstMap.put("timeInterval", timeMap);


        return rstMap;
    }

    /**
     * 线路区域不良行为排名 - 黑点/全部排名/分页
     *
     * @param vo
     * @return
     */
    public Pagination getLineAreaBadBhvSort4BPage(lineDrvStandardVo vo) {
        Pagination page = this.myBatisPage(
                "lineDrvStandard.getLineAreaBadBhvSort4BCnt",
                "lineDrvStandard.getLineAreaBadBhvSort4BPage", vo, LineAreaBadBhvSortVo.class);
        return page;
    }

    /**
     * 线路区域不良行为排名 - 站点/全部排名/分页
     *
     * @param vo
     * @return
     */
    public Pagination getLineAreaBadBhvSort4SPage(lineDrvStandardVo vo) {
        Pagination page = this.myBatisPage(
                "lineDrvStandard.getLineAreaBadBhvSort4SCnt",
                "lineDrvStandard.getLineAreaBadBhvSort4SPage", vo, LineAreaBadBhvSortVo.class);
        return page;
    }

    /**
     * 线路区域不良行为排名 - 站点区间/全部排名/分页
     *
     * @param vo
     * @return
     */
    public Pagination getLineAreaBadBhvSort4BSPage(lineDrvStandardVo vo) {
        Pagination page = this.myBatisPage(
                "lineDrvStandard.getLineAreaBadBhvSort4BSCnt",
                "lineDrvStandard.getLineAreaBadBhvSort4BSPage", vo, LineAreaBadBhvSortVo.class);
        return page;
    }

    // todo 线路区域不良行为统计

    /**
     * 线路区域不良行为统计
     *
     * @param vo
     * @return
     */
    public List<LineAreaBadBhvSortVo> getLineAreaBadBhvCntList(lineDrvStandardVo vo) {
        String filterConditionSql = getBhvList4fltSql("SUM_BAD_BHV_FREQ");
        vo.setFilterConditionSql(filterConditionSql);

        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getLineAreaBadBhvCntList", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);

        return dataList;
    }

    // todo 区域不良行为趋势图数据

    public Map getLineAreaBadBhvTrendList(lineDrvStandardVo vo) {
        Map rstMap = new HashMap();

        // 获取日期类型所对应的日期区间
        String dateTy = vo.getDateTy();
        vo.setTdateTy(dateTy);
        if ("02".equals(dateTy)) {// 如果查询"昨天"，就去"近7天"的数据
            vo.setTdateTy("03");
        }
        dateType2DateTime(vo);


        // 查询数据
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getLineAreaBadBhvTrendList", vo);


        // 封装数据
        Map tmap1 = new HashMap();// B:黑点区域
        Map tmap2 = new HashMap();// S：站点区域
        Map tmap3 = new HashMap();// BS：站点间区域
        Map tmap4 = new HashMap();// OL：非营运
        Map tmap5 = new HashMap();// T：汇总数据

        Map tmap = null;
        for (int i = 0; i < dataMap.size(); i++) {
            tmap = dataMap.get(i);

            if ("B".equals(tmap.get("AREA_TYPE"))) {
                tmap1.put(tmap.get("CDATE"), tmap.get("FREQ"));
            } else if ("S".equals(tmap.get("AREA_TYPE"))) {
                tmap2.put(tmap.get("CDATE"), tmap.get("FREQ"));
            } else if ("BS".equals(tmap.get("AREA_TYPE"))) {
                tmap3.put(tmap.get("CDATE"), tmap.get("FREQ"));
            } else if ("OL".equals(tmap.get("AREA_TYPE"))) {
                tmap4.put(tmap.get("CDATE"), tmap.get("FREQ"));
            } else if ("T".equals(tmap.get("AREA_TYPE"))) {
                tmap5.put(tmap.get("CDATE"), tmap.get("FREQ"));
            }
        }


        // 根据时间区间，按月/日取时间数组
        String timeType = "day";
        if ("06".equals(vo.getTdateTy()) || "07".equals(vo.getTdateTy())) {// 按月取数
            timeType = "month";
        }
        String[] timeArr = getTimeArrByTimeInterval(timeType, vo.getBeginTime(), vo.getEndTime());

        Map rmap1 = new LinkedHashMap();// B:黑点区域
        Map rmap2 = new LinkedHashMap();// S：站点区域
        Map rmap3 = new LinkedHashMap();// BS：站点间区域
        Map rmap4 = new LinkedHashMap();// OL：非营运
        Map rmap5 = new LinkedHashMap();// T：汇总数据
        for (int i = 0; i < timeArr.length; i++) {
            String cdate = timeArr[i];

            // B:黑点区域
            if (PubUtil.isNotEmpty(tmap1)) {
                if (tmap1.containsKey(cdate)) {// 有值
                    rmap1.put(cdate, tmap1.get(cdate));
                } else {// 没有值
                    rmap1.put(cdate, 0);
                }
            }

            // S：站点区域
            if (PubUtil.isNotEmpty(tmap2)) {
                if (tmap2.containsKey(cdate)) {// 有值
                    rmap2.put(cdate, tmap2.get(cdate));
                } else {// 没有值
                    rmap2.put(cdate, 0);
                }
            }


            // BS：站点间区域
            if (PubUtil.isNotEmpty(tmap3)) {
                if (tmap3.containsKey(cdate)) {// 有值
                    rmap3.put(cdate, tmap3.get(cdate));
                } else {// 没有值
                    rmap3.put(cdate, 0);
                }
            }


            // OL：非营运
            if (PubUtil.isNotEmpty(tmap4)) {
                if (tmap4.containsKey(cdate)) {// 有值
                    rmap4.put(cdate, tmap4.get(cdate));
                } else {// 没有值
                    rmap4.put(cdate, 0);
                }
            }


            // T：汇总数据
            if (PubUtil.isNotEmpty(tmap5)) {
                if (tmap5.containsKey(cdate)) {// 有值
                    rmap5.put(cdate, tmap5.get(cdate));
                } else {// 没有值
                    rmap5.put(cdate, 0);
                }
            }
        }


        // 获取日期类型所对应的日期区间
        Map timeMap = new HashMap();
        if (PubUtil.isNotEmpty(timeArr)) {
            timeMap.put("beginTime", timeArr[0]);
            timeMap.put("endTime", timeArr[timeArr.length - 1]);
        }


        rstMap.put("blackSpot", rmap1);
        rstMap.put("site", rmap2);
        rstMap.put("siteInterval", rmap3);
        rstMap.put("noOpt", rmap4);
        rstMap.put("totalCnt", rmap5);
        rstMap.put("timeInterval", timeMap);


        return rstMap;
    }


    // todo 驾驶员不良行为数量排名

    /**
     * 驾驶员不良行为数量排名 - 前5
     *
     * @param vo
     * @return
     */
    public List<LineAreaBadBhvSortVo> getDrvBadBhvCntSortList(lineDrvStandardVo vo) {
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getDrvBadBhvCntSortList", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);

        return dataList;
    }

    /**
     * 驾驶员不良行为数量排名 - 全部/分页
     *
     * @param vo
     * @return
     */
    public Pagination getDrvBadBhvCntSortPage(lineDrvStandardVo vo) {
        Pagination page = this.myBatisPage(
                "lineDrvStandard.getDrvBadBhvCntSortCnt",
                "lineDrvStandard.getDrvBadBhvCntSortPage", vo, LineAreaBadBhvSortVo.class);
        return page;
    }

    // todo 地图行为分布

    /**
     * 地图行为分布
     *
     * @param vo
     * @return
     */
    public List<LineAreaBadBhvSortVo> getBadBhvMapData(lineDrvStandardVo vo) {
        // 上下行数值转化
        if ("B".equals(vo.getAreaType())) {// 黑点
            if ("LIT00001".equals(vo.getLineTy())) {
                vo.setLineTy("0");
            } else {
                vo.setLineTy("1");
            }
        }


        // 获取行为地图分布-区域信息
        List<LineAreaBadBhvSortVo> dataList = getBadBhvMapAreaInfo(vo);

        if (PubUtil.isNotEmpty(dataList)) {
            LineAreaBadBhvSortVo vo1 = null;
            for (int i = 0; i < dataList.size(); i++) {
                vo1 = dataList.get(i);

                vo.setAreaId(vo1.getAreaId());

                // 获取行为地图分布-不良行为规范
                List<LineAreaBadBhvSortVo> dataList1 = getBadBhvMapStandardInfo(vo);
                // 获取行为地图分布-不良行为排名
                List<LineAreaBadBhvSortVo> dataList2 = getBadBhvMapSortInfo(vo);

                vo1.setBadBhvStandard(dataList1);
                vo1.setBadBhvSort(dataList2);
            }
        }

        return dataList;
    }

    // todo 时间行为分布

    /**
     * 时间行为分布
     *
     * @param vo
     * @return
     */
    public LineAreaBadBhvSortVo getBadBhvTimeDist(lineDrvStandardVo vo) {
        // 上下行数值转化
        if ("B".equals(vo.getAreaType())) {// 黑点
            if ("LIT00001".equals(vo.getLineTy())) {
                vo.setLineTy("0");
            } else {
                vo.setLineTy("1");
            }
        }


        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getBadBhvTimeDist", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);

        if (PubUtil.isNotEmpty(dataList)) {
            return dataList.get(0);
        }

        return null;
    }

    // todo 城市不良行为热力图

    /**
     * 城市不良行为热力图
     *
     * @param vo
     * @return
     */
    public List<LineAreaBadBhvSortVo> getCityBadBhvTherDiagData(lineDrvStandardVo vo) {
        // 获取日期类型所对应的日期区间
        String dateTy = vo.getDateTy();
        vo.setTdateTy(dateTy);
        dateType2DateTime(vo);

        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getCityBadBhvTherDiagData", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);


        return dataList;
    }

    /**
     * 城市不良行为热力图-区域数据统计
     *
     * @param vo
     * @return
     */
    public Map getCityBadBhvTherDiagAreaStatis(lineDrvStandardVo vo) {
        Map rstMap = new HashMap();

        // 获取日期类型所对应的日期区间
        String dateTy = vo.getDateTy();
        vo.setTdateTy(dateTy);
        dateType2DateTime(vo);

        // 不良行为排名
        List<Map> dataMap1 = this.sqlMapDao.selectList("lineDrvStandard.getCityBadBhvTherDiagBhvSort", vo);
        List<LineAreaBadBhvSortVo> dataList1 = PubUtil.convertListMapToObject(dataMap1, LineAreaBadBhvSortVo.class);

        // 驾驶员排名（取前三）
        List<Map> dataMap2 = this.sqlMapDao.selectList("lineDrvStandard.getCityBadBhvTherDiagDrvSort", vo);
        List<LineAreaBadBhvSortVo> dataList2 = PubUtil.convertListMapToObject(dataMap2, LineAreaBadBhvSortVo.class);


        rstMap.put("bhvSortInfo", dataList1);
        rstMap.put("drvSortInfo", dataList2);


        return rstMap;
    }

    // todo 获取不良行为列表

    /**
     * 获取不良行为列表
     *
     * @return
     */
    public List<ModTyBadBhvTypeEntity> getBadBhvList() {
        List<ModTyBadBhvTypeEntity> dataList = this.commonEntityDao.findAll(ModTyBadBhvTypeEntity.class);

        return dataList;
    }

    // todo 区域不良行为明细

    /**
     * 区域不良行为明细
     *
     * @param vo
     * @return
     */
    @Transactional //@Transactional 让临时表操作处于同一个事物中
    @LeftOrgAnnotation()
    public Pagination getAreaBadBhvDetailPage(lineDrvStandardVo vo) throws Exception {
        // 查询数据
        Pagination page = this.myBatisPage(
                "lineDrvStandard.getAreaBadBhvDetailCnt",
                "lineDrvStandard.getAreaBadBhvDetailList", vo, ModTyBadBhvInfoEntity.class);

        // 填充数据
        List list = page.getData();

        Map map = new HashMap();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);

        map = new HashMap();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("organId", map);

        map = new HashMap();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo3 = new FillParamsVo("drvId", map);

        codeDscValue.fillInfoValue(list, new String[]{
                GlobalConst.CACHE_KEY_BASE_LINE_INFO,
                GlobalConst.CACHE_KEY_BASE_ORGAN,
                GlobalConst.CACHE_KEY_BASE_DRV_INFO}, vo1, vo2, vo3);

        map = new HashMap();
        map.put("areaType", "LIAREA00");
        codeDscValue.fillCodeDscValue(list, map);

        page.setData(list);

        return page;
    }

    /**
     * 导出-区域不良行为明细
     *
     * @param vo
     * @return
     */
    @Transactional //@Transactional 让临时表操作处于同一个事物中
    @LeftOrgAnnotation()
    public List getAreaBadBhvDetail(lineDrvStandardVo vo) throws Exception {
        // 查询数据
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getAreaBadBhvDetailList", vo);
        List dataList = PubUtil.convertListMapToObject(dataMap, ModTyBadBhvInfoEntity.class);

        // 填充数据
        Map map = new HashMap();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);

        map = new HashMap();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("organId", map);

        map = new HashMap();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo3 = new FillParamsVo("drvId", map);

        codeDscValue.fillInfoValue(dataList, new String[]{
                GlobalConst.CACHE_KEY_BASE_LINE_INFO,
                GlobalConst.CACHE_KEY_BASE_ORGAN,
                GlobalConst.CACHE_KEY_BASE_DRV_INFO}, vo1, vo2, vo3);

        map = new HashMap();
        map.put("areaType", "LIAREA00");
        codeDscValue.fillCodeDscValue(dataList, map);

        return dataList;
    }

    // todo 线路驾驶规范

    /**
     * 线路驾驶规范
     *
     * @param vo
     * @return
     */
    @Transactional
    @LeftOrgAnnotation()
    public Pagination getLineDrvStandardPage(lineDrvStandardVo vo) {
        // 转化线路类型的值
        if ("S".equals(vo.getAreaType())) {
            if ("0".equals(vo.getLineTy())) {
                vo.setLineTy("LIT00001");
            } else if ("1".equals(vo.getLineTy())) {
                vo.setLineTy("LIT00002");
            }
        }

        // 查询数据
        Pagination page = this.myBatisPage(
                "lineDrvStandard.getLineDrvStandardCnt",
                "lineDrvStandard.getLineDrvStandardList", vo, ModTyBadBhvBencEntity.class);

        // 填充数据
        List list = page.getData();

        Map map = new HashMap();
        map.put("areaType", "LIAREA00");
        codeDscValue.fillCodeDscValue(list, map);

        page.setData(list);

        return page;
    }

    /**
     * 导出-线路驾驶规范
     *
     * @param vo
     * @return
     */
    @Transactional //@Transactional 让临时表操作处于同一个事物中
    @LeftOrgAnnotation()
    public List exportLineDrvStandard(lineDrvStandardVo vo) throws Exception {
        // 转化线路类型的值
        if ("S".equals(vo.getAreaType())) {
            if ("0".equals(vo.getLineTy())) {
                vo.setLineTy("LIT00001");
            } else if ("1".equals(vo.getLineTy())) {
                vo.setLineTy("LIT00002");
            }
        }

        // 查询数据
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getLineDrvStandardList", vo);
        List dataList = PubUtil.convertListMapToObject(dataMap, ModTyBadBhvBencEntity.class);

        // 填充值
        Map map = new HashMap();
        map.put("areaType", "LIAREA00");
        codeDscValue.fillCodeDscValue(dataList, map);

        return dataList;
    }

    /**
     * 获取行为地图分布-不良行为排名
     *
     * @param vo
     * @return
     */
    private List<LineAreaBadBhvSortVo> getBadBhvMapSortInfo(lineDrvStandardVo vo) {
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getBadBhvMapSortInfo", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);
        return dataList;
    }


    /**
     * 获取行为地图分布-不良行为规范
     *
     * @param vo
     * @return
     */
    private List<LineAreaBadBhvSortVo> getBadBhvMapStandardInfo(lineDrvStandardVo vo) {
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getBadBhvMapStandardInfo", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);
        return dataList;
    }


    /**
     * 获取行为地图分布-区域信息
     *
     * @param vo
     * @return
     */
    private List<LineAreaBadBhvSortVo> getBadBhvMapAreaInfo(lineDrvStandardVo vo) {
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getBadBhvMapAreaInfo", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);
        return dataList;
    }


    /**
     * 获取日期类型所对应的日期区间
     *
     * @param vo
     */
    private void dateType2DateTime(lineDrvStandardVo vo) {
        Map<String, Object> prmMap = new HashMap<String, Object>();
        prmMap.put("lineId", vo.getLineId());
        prmMap.put("cdateTy", vo.getTdateTy());
        prmMap.put("tableN", "T_MOD_TY_BAD_BHV_INFO");

        List<ModDateTyAutoEntity> list = this.commonEntityDao.findByParamsIgnoreNullValue(ModDateTyAutoEntity.class, prmMap);

        if (PubUtil.isNotEmpty(list)) {
            ModDateTyAutoEntity entity = list.get(0);

            vo.setBeginTime(entity.getRangeFrom());
            vo.setEndTime(entity.getRangeTo());
        }
    }

    /**
     * 根据时间区间，按月/日取时间数组
     *
     * @param timeType
     * @param beginTime
     * @param endTime
     * @return
     */
    private String[] getTimeArrByTimeInterval(String timeType, String beginTime, String endTime) {
        Map<String, Object> prmMap = new HashMap<String, Object>();
        prmMap.put("timeType", timeType);
        prmMap.put("beginTime", beginTime);
        prmMap.put("endTime", endTime);

        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getTimeArrByTimeInterval", prmMap);

        String[] timeArr = new String[dataMap.size()];
        for (int i = 0; i < dataMap.size(); i++) {
            timeArr[i] = (String) dataMap.get(i).get("STR_DATE");
        }

        return timeArr;
    }

    /**
     * 动态sql部分
     *
     * @param column1
     * @return
     */
    private String getBhvList4fltSql(String column1) {
        List<ModTyBadBhvTypeEntity> list = this.commonEntityDao.findAll(ModTyBadBhvTypeEntity.class);

        String filterConditionSql = "";
        if (PubUtil.isNotEmpty(list)) {
            ModTyBadBhvTypeEntity entity;
            for (int i = 0; i < list.size(); i++) {
                entity = list.get(i);

                filterConditionSql += ",\nSUM(CASE WHEN A.BAD_BHV_ID = '" + entity.getBadBhvId() + "'\n" +
                        "            THEN A." + column1 + "\n" +
                        "              ELSE 0 END)         BAD_BHV_" + (i + 1) + "\n";
            }
        }

        return filterConditionSql;
    }

    /**
     * 获取统计的不良行为列表
     *
     * @return
     */
    private Map<String, Object> getBadBhvInfo() {
        Map<String, Object> rstMap = new HashMap<String, Object>();

        List<ModTyBadBhvTypeEntity> list = this.commonEntityDao.findAll(ModTyBadBhvTypeEntity.class);

        if (PubUtil.isNotEmpty(list)) {
            ModTyBadBhvTypeEntity entity;
            for (int i = 0; i < list.size(); i++) {
                entity = list.get(i);

                rstMap.put("badBhv" + (i + 1), entity.getBadBhvName());
            }
        }

        return rstMap;
    }

    /**
     * 线路区域不良行为排名-区域类型下的数据
     *
     * @param vo
     * @return
     */
    private List<LineAreaBadBhvSortVo> getLineAreaBadBhvSortListByAreaType(lineDrvStandardVo vo) {
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getLineAreaBadBhvSortListByAreaType", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);
        return dataList;
    }

    /**
     * 线路区域不良行为排名-各区域类型所有不良行为的总数量及环比上升/下降比率
     *
     * @param vo
     * @return
     */
    private List<LineAreaBadBhvSortVo> getLineAreaBadBhvInfoList(lineDrvStandardVo vo) {
        List<Map> dataMap = this.sqlMapDao.selectList("lineDrvStandard.getLineAreaBadBhvInfoList", vo);
        List<LineAreaBadBhvSortVo> dataList = PubUtil.convertListMapToObject(dataMap, LineAreaBadBhvSortVo.class);
        return dataList;
    }

}
